package test.br.com.lh.urabuilder.view
{
	import br.com.lh.urabuilder.business.ArrowManagerImpl;
	import br.com.lh.urabuilder.view.ActionComponent;
	import br.com.lh.urabuilder.view.arrow.ArrowContainer;
	
	import flash.geom.Point;
	
	import flexunit.framework.TestCase;
	import flexunit.framework.TestSuite;

	public class ArrowContainerTest extends TestCase
	{
		private var initialPoint:Point = new Point(0,0);
		private	var endPoint:Point = new Point(10,0);
		
		
		public function ArrowContainerTest(methodName:String=null)
		{
			super(methodName);
		}
		
		public static function suite():TestSuite{
			var ts:TestSuite = new TestSuite();
			ts.addTest(new ArrowContainerTest("shouldHaveCorrectAngle"));
			ts.addTest(new ArrowContainerTest("deleted_arrow_should_be_removed_from_initial_element_out_array"));
			ts.addTest(new ArrowContainerTest("deleted_arrow_should_be_removed_from_end_element_entry_array"));
			return ts;
		}
		
		public function shouldHaveCorrectAngle():void{
			var arrowContainer:ArrowContainer = new ArrowContainer(initialPoint,endPoint);
			assertEquals(0,arrowContainer.rotation);
			endPoint= new Point(10,10);
			arrowContainer= new ArrowContainer(initialPoint,endPoint);
			assertEquals(45,arrowContainer.rotation);
		}
		
		public function deleted_arrow_should_be_removed_from_initial_element_out_array():void{
			var arrowContainer:ArrowContainer = new ArrowContainer(initialPoint,endPoint);
			var startComponent:ActionComponent = new ActionComponent();
			arrowContainer.startComponent = startComponent;
			arrowContainer.remove();
			assertFalse(startComponent.outArrows.contains(arrowContainer));
		}
		
		public function deleted_arrow_should_be_removed_from_end_element_entry_array():void{
			var arrowContainer:ArrowContainer = new ArrowContainer(initialPoint,endPoint);
			var endComponent:ActionComponent = new ActionComponent();
			arrowContainer.endComponent= endComponent;
			arrowContainer.remove();
			assertFalse(endComponent.entryArrows.contains(arrowContainer));
		}
			
		
		
	}
}